package com.snpic.appaw.module.insure.api.cxProvince;

import cn.hutool.core.bean.BeanUtil;
import com.snpic.appaw.framework.common.pojo.CommonResult;
import com.snpic.appaw.framework.common.pojo.PageResult;
import com.snpic.appaw.framework.common.util.object.BeanUtils;
import com.snpic.appaw.module.insure.api.cxProvince.dto.AppCxProvincePageReqDTO;
import com.snpic.appaw.module.insure.api.cxProvince.dto.AppCxProvinceRespDTO;
import com.snpic.appaw.module.insure.controller.app.cxProvince.vo.AppCxProvincePageReqVO;
import com.snpic.appaw.module.insure.dal.dataobject.cxProvince.CxProvinceDO;
import com.snpic.appaw.module.insure.service.cxProvince.CxProvinceService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import static com.snpic.appaw.framework.common.pojo.CommonResult.success;

/**
 * @author JiJun
 * @date 2025/9/17 18:52
 * @修改时间 2025/9/17 18:52
 * @description
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class CxProvinceApiImpl implements CxProvinceApi {
	@Resource
	private CxProvinceService cxProvinceService;

	public CommonResult<PageResult<AppCxProvinceRespDTO>> getCxProvincePage(@Valid AppCxProvincePageReqDTO pageReqDTO) {

		AppCxProvincePageReqVO pageReqVO = BeanUtil.copyProperties(pageReqDTO, AppCxProvincePageReqVO.class);

		PageResult<CxProvinceDO> pageResult = cxProvinceService.getCxProvincePage(pageReqVO);

		return success(BeanUtils.toBean(pageResult, AppCxProvinceRespDTO.class));
	}

}
